package com.example.controller;

import com.example.model.Customer;
import com.example.service.DiscountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RestController
public class DiscountController {

    @Autowired
    private DiscountService discountService;

    @GetMapping("/hello")
    public String hello(){
        return "Hello";
    }

    @GetMapping("/getCustomer")
    public Customer getCustomer(@RequestParam String idCard){
        Customer customer = discountService.getCustomer(idCard);
        if (customer==null){
            return new Customer();
        }
        return customer;
    }

    @GetMapping("/getVipLevel")
    public String getVipLevel(String idCard){
        //获取customer信息
        Customer customer = discountService.getCustomer(idCard);
        //判断VIP等级
        if (customer.getVipType()==null){
            return "非VIP用户";
        }else
        return customer.getVipType();
    }

    @GetMapping("/discount")
    public String getDiscount(@RequestParam String itemName,
                              @RequestParam String vipLevel,
                              @RequestParam BigDecimal privce)
}
